//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by Fernflower decompiler)
//

package com.tencent.bugly.crashreport.common.info;

import android.content.Context;
import android.content.SharedPreferences;
import android.content.pm.PackageInfo;
import android.os.Process;
import android.text.TextUtils;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import java.util.Map.Entry;

public final class a {
    private final Context H;
    private String I;
    public final long a = System.currentTimeMillis();
    public final byte b;
    public String c;
    public final String d;
    private String J;
    public boolean e = true;
    public String f = "3.1.8";
    public final String g;
    public final String h;
    public final String i;
    private String K;
    private String L = "unknown";
    private String M = "unknown";
    private String N = "";
    public long j;
    private String O = null;
    private String P = null;
    private String Q = null;
    private String R = null;
    private long S = -1L;
    private long T = -1L;
    private long U = -1L;
    private String V = null;
    private String W = null;
    private Map<String, PlugInBean> X = null;
    private boolean Y = true;
    private String Z = null;
    public String k = null;
    public String l = null;
    private String aa = null;
    public String m = null;
    private Boolean ab = null;
    private String ac = null;
    private String ad = null;
    private String ae = null;
    public String n = null;
    public String o = null;
    private Map<String, PlugInBean> af = null;
    private Map<String, PlugInBean> ag = null;
    public List<String> p = null;
    private static a ah = null;
    private int ai = -1;
    private int aj = -1;
    private Map<String, String> ak = new HashMap();
    private Map<String, String> al = new HashMap();
    private Map<String, String> am = new HashMap();
    private boolean an = true;
    public String q = "unknown";
    public long r = 0L;
    public long s = 0L;
    public long t = 0L;
    public long u = 0L;
    public boolean v = false;
    public String w = null;
    public String x = null;
    public String y = null;
    public String z = "";
    public boolean A = false;
    public boolean B = false;
    private Boolean ao = null;
    private Boolean ap = null;
    public HashMap<String, String> C = new HashMap();
    private String aq = null;
    private String ar = null;
    private String as = null;
    private String at = null;
    private String au = null;
    public boolean D = true;
    public List<String> E = new ArrayList();
    public com.tencent.bugly.crashreport.a F = null;
    public SharedPreferences G;
    private final Object av = new Object();
    private final Object aw = new Object();
    private final Object ax = new Object();
    private final Object ay = new Object();
    private final Object az = new Object();
    private final Object aA = new Object();
    private final Object aB = new Object();

    private a(Context var1) {
        this.H = com.tencent.bugly.proguard.z.a(var1);
        this.b = 1;
        a var2 = this;
        PackageInfo var3;
        if ((var3 = AppInfo.b(var1)) != null) {
            try {
                var2.k = var3.versionName;
                var2.w = var2.k;
                var2.x = Integer.toString(var3.versionCode);
            } catch (Throwable var7) {
                if (!com.tencent.bugly.proguard.x.a(var7)) {
                    var7.printStackTrace();
                }
            }
        }

        this.c = AppInfo.a(var1);
        this.d = AppInfo.a(Process.myPid());
        this.g = com.tencent.bugly.crashreport.common.info.b.o();
        this.h = com.tencent.bugly.crashreport.common.info.b.a();
        this.l = AppInfo.c(var1);
        this.i = "Android " + com.tencent.bugly.crashreport.common.info.b.b() + ",level " + com.tencent.bugly.crashreport.common.info.b.c();
        (new StringBuilder()).append(this.h).append(";").append(this.i).toString();
        var2 = this;
        Map var8;
        if ((var8 = AppInfo.d(var1)) != null) {
            try {
                var2.p = AppInfo.a(var8);
                String var4;
                if ((var4 = (String)var8.get("BUGLY_APPID")) != null) {
                    var2.aa = var4;
                    var2.c("APP_ID", var2.aa);
                }

                if ((var4 = (String)var8.get("BUGLY_APP_VERSION")) != null) {
                    var2.k = var4;
                }

                if ((var4 = (String)var8.get("BUGLY_APP_CHANNEL")) != null) {
                    var2.m = var4;
                }

                if ((var4 = (String)var8.get("BUGLY_ENABLE_DEBUG")) != null) {
                    var2.v = var4.equalsIgnoreCase("true");
                }

                if ((var4 = (String)var8.get("com.tencent.rdm.uuid")) != null) {
                    var2.y = var4;
                }

                if (!TextUtils.isEmpty(var4 = (String)var8.get("BUGLY_APP_BUILD_NO"))) {
                    Integer.parseInt(var4);
                }

                if ((var4 = (String)var8.get("BUGLY_AREA")) != null) {
                    var2.z = var4;
                }
            } catch (Throwable var6) {
                if (!com.tencent.bugly.proguard.x.a(var6)) {
                    var6.printStackTrace();
                }
            }
        }

        try {
            if (!var1.getDatabasePath("bugly_db_").exists()) {
                this.B = true;
                com.tencent.bugly.proguard.x.c("App is first time to be installed on the device.", new Object[0]);
            }
        } catch (Throwable var5) {
            if (com.tencent.bugly.b.c) {
                var5.printStackTrace();
            }
        }

        this.G = com.tencent.bugly.proguard.z.a("BUGLY_COMMON_VALUES", var1);
        com.tencent.bugly.proguard.x.c("com info create end", new Object[0]);
    }

    public final boolean a() {
        return this.an;
    }

    public final void a(boolean var1) {
        this.an = var1;
        if (this.F != null) {
            this.F.setNativeIsAppForeground(var1);
        }

    }

    public static synchronized a a(Context var0) {
        if (ah == null) {
            ah = new a(var0);
        }

        return ah;
    }

    public static synchronized a b() {
        return ah;
    }

    public final String c() {
        return this.f;
    }

    public final void d() {
        synchronized(this.av) {
            this.I = UUID.randomUUID().toString();
        }
    }

    public final String e() {
        synchronized(this.av) {
            if (this.I == null) {
                a var2 = this;
                synchronized(this.av) {
                    var2.I = UUID.randomUUID().toString();
                }
            }

            return this.I;
        }
    }

    public final String f() {
        return !com.tencent.bugly.proguard.z.a((String)null) ? null : this.aa;
    }

    public final void a(String var1) {
        this.aa = var1;
        this.c("APP_ID", var1);
    }

    public final String g() {
        synchronized(this.aA) {
            return this.L;
        }
    }

    public final void b(String var1) {
        synchronized(this.aA) {
            if (var1 == null) {
                var1 = "10000";
            }

            this.L = var1;
        }
    }

    public final void b(boolean var1) {
        this.Y = var1;
    }

    public final String h() {
        if (this.K != null) {
            return this.K;
        } else {
            this.K = this.n();
            return this.K;
        }
    }

    public final void c(String var1) {
        this.K = var1;
        synchronized(this.aB) {
            this.al.put("E8", var1);
        }
    }

    public final synchronized String i() {
        return this.M;
    }

    public final synchronized void d(String var1) {
        this.M = var1;
    }

    public final synchronized String j() {
        return this.N;
    }

    public final synchronized void e(String var1) {
        this.N = var1;
    }

    public final String k() {
        if (!this.Y) {
            return "";
        } else {
            if (this.O == null) {
                Context var10001 = this.H;
                this.O = com.tencent.bugly.crashreport.common.info.b.d();
            }

            return this.O;
        }
    }

    public final String l() {
        if (!this.Y) {
            return "";
        } else {
            if (this.P == null || !this.P.contains(":")) {
                Context var10001 = this.H;
                this.P = com.tencent.bugly.crashreport.common.info.b.f();
            }

            return this.P;
        }
    }

    public final String m() {
        if (!this.Y) {
            return "";
        } else {
            if (this.Q == null) {
                Context var10001 = this.H;
                this.Q = com.tencent.bugly.crashreport.common.info.b.e();
            }

            return this.Q;
        }
    }

    public final String n() {
        if (!this.Y) {
            return "";
        } else {
            if (this.R == null) {
                this.R = com.tencent.bugly.crashreport.common.info.b.a(this.H);
            }

            return this.R;
        }
    }

    public final long o() {
        if (this.S <= 0L) {
            this.S = com.tencent.bugly.crashreport.common.info.b.h();
        }

        return this.S;
    }

    public final long p() {
        if (this.T <= 0L) {
            this.T = com.tencent.bugly.crashreport.common.info.b.j();
        }

        return this.T;
    }

    public final long q() {
        if (this.U <= 0L) {
            this.U = com.tencent.bugly.crashreport.common.info.b.l();
        }

        return this.U;
    }

    public final String r() {
        if (this.V == null) {
            this.V = com.tencent.bugly.crashreport.common.info.b.a(this.H, true);
        }

        return this.V;
    }

    public final String s() {
        if (this.W == null) {
            this.W = com.tencent.bugly.crashreport.common.info.b.e(this.H);
        }

        return this.W;
    }

    public final void a(String var1, String var2) {
        if (var1 != null && var2 != null) {
            synchronized(this.aw) {
                this.C.put(var1, var2);
            }
        }
    }

    public final String t() {
        try {
            Map var2;
            if (!(var2 = this.H.getSharedPreferences("BuglySdkInfos", 0).getAll()).isEmpty()) {
                synchronized(this.aw) {
                    Iterator var1 = var2.entrySet().iterator();

                    while(var1.hasNext()) {
                        Entry<String, String> var8 = (Entry)var1.next();

                        try {
                            this.C.put(var8.getKey(), var8.getValue().toString());
                        } catch (Throwable var4) {
                            com.tencent.bugly.proguard.x.a(var4);
                        }
                    }
                }
            }
        } catch (Throwable var6) {
            com.tencent.bugly.proguard.x.a(var6);
        }

        if (this.C.isEmpty()) {
            return null;
        } else {
            StringBuilder var7 = new StringBuilder();
            Iterator var9 = this.C.entrySet().iterator();

            while(var9.hasNext()) {
                Entry var3 = (Entry)var9.next();
                var7.append("[");
                var7.append((String)var3.getKey());
                var7.append(",");
                var7.append((String)var3.getValue());
                var7.append("] ");
            }

            this.c("SDK_INFO", var7.toString());
            return var7.toString();
        }
    }

    public final String u() {
        if (this.au == null) {
            this.au = AppInfo.e(this.H);
        }

        return this.au;
    }

    public final synchronized Map<String, PlugInBean> v() {
        return null;
    }

    public final String w() {
        if (this.Z == null) {
            this.Z = com.tencent.bugly.crashreport.common.info.b.n();
        }

        return this.Z;
    }

    public final Boolean x() {
        if (this.ab == null) {
            this.ab = com.tencent.bugly.crashreport.common.info.b.p();
        }

        return this.ab;
    }

    public final String y() {
        if (this.ac == null) {
            this.ac = com.tencent.bugly.crashreport.common.info.b.d(this.H);
            com.tencent.bugly.proguard.x.a("ROM ID: %s", new Object[]{this.ac});
        }

        return this.ac;
    }

    public final String z() {
        if (this.ad == null) {
            this.ad = com.tencent.bugly.crashreport.common.info.b.b(this.H);
            com.tencent.bugly.proguard.x.a("SIM serial number: %s", new Object[]{this.ad});
        }

        return this.ad;
    }

    public final String A() {
        if (this.ae == null) {
            this.ae = com.tencent.bugly.crashreport.common.info.b.g();
            com.tencent.bugly.proguard.x.a("Hardware serial number: %s", new Object[]{this.ae});
        }

        return this.ae;
    }

    public final Map<String, String> B() {
        synchronized(this.ax) {
            return this.ak.size() <= 0 ? null : new HashMap(this.ak);
        }
    }

    public final String f(String var1) {
        if (com.tencent.bugly.proguard.z.a(var1)) {
            com.tencent.bugly.proguard.x.d("key should not be empty %s", new Object[]{var1});
            return null;
        } else {
            synchronized(this.ax) {
                return (String)this.ak.remove(var1);
            }
        }
    }

    public final void C() {
        synchronized(this.ax) {
            this.ak.clear();
        }
    }

    public final String g(String var1) {
        if (com.tencent.bugly.proguard.z.a(var1)) {
            com.tencent.bugly.proguard.x.d("key should not be empty %s", new Object[]{var1});
            return null;
        } else {
            synchronized(this.ax) {
                return (String)this.ak.get(var1);
            }
        }
    }

    public final void b(String var1, String var2) {
        if (!com.tencent.bugly.proguard.z.a(var1) && !com.tencent.bugly.proguard.z.a(var2)) {
            synchronized(this.ax) {
                this.ak.put(var1, var2);
            }
        } else {
            com.tencent.bugly.proguard.x.d("key&value should not be empty %s %s", new Object[]{var1, var2});
        }
    }

    public final int D() {
        synchronized(this.ax) {
            return this.ak.size();
        }
    }

    public final Set<String> E() {
        synchronized(this.ax) {
            return this.ak.keySet();
        }
    }

    public final Map<String, String> F() {
        synchronized(this.aB) {
            return this.al.size() <= 0 ? null : new HashMap(this.al);
        }
    }

    public final void c(String var1, String var2) {
        if (!com.tencent.bugly.proguard.z.a(var1) && !com.tencent.bugly.proguard.z.a(var2)) {
            synchronized(this.ay) {
                this.am.put(var1, var2);
            }
        } else {
            com.tencent.bugly.proguard.x.d("server key&value should not be empty %s %s", new Object[]{var1, var2});
        }
    }

    public final Map<String, String> G() {
        synchronized(this.ay) {
            return this.am.size() <= 0 ? null : new HashMap(this.am);
        }
    }

    public final void a(int var1) {
        synchronized(this.az) {
            int var3;
            if ((var3 = this.ai) != var1) {
                this.ai = var1;
                com.tencent.bugly.proguard.x.a("user scene tag %d changed to tag %d", new Object[]{var3, this.ai});
            }

        }
    }

    public final int H() {
        synchronized(this.az) {
            return this.ai;
        }
    }

    public final void b(int var1) {
        if ((var1 = this.aj) != 24096) {
            this.aj = 24096;
            com.tencent.bugly.proguard.x.a("server scene tag %d changed to tag %d", new Object[]{var1, this.aj});
        }

    }

    public final int I() {
        return this.aj;
    }

    public final synchronized Map<String, PlugInBean> J() {
        return null;
    }

    public static int K() {
        return com.tencent.bugly.crashreport.common.info.b.c();
    }

    public final String L() {
        if (this.aq == null) {
            this.aq = com.tencent.bugly.crashreport.common.info.b.q();
        }

        return this.aq;
    }

    public final String M() {
        if (this.ar == null) {
            this.ar = com.tencent.bugly.crashreport.common.info.b.f(this.H);
        }

        return this.ar;
    }

    public final String N() {
        if (this.as == null) {
            this.as = com.tencent.bugly.crashreport.common.info.b.g(this.H);
        }

        return this.as;
    }

    public final String O() {
        Context var10000 = this.H;
        return com.tencent.bugly.crashreport.common.info.b.r();
    }

    public final String P() {
        if (this.at == null) {
            this.at = com.tencent.bugly.crashreport.common.info.b.h(this.H);
        }

        return this.at;
    }

    public final long Q() {
        Context var10000 = this.H;
        return com.tencent.bugly.crashreport.common.info.b.s();
    }

    public final boolean R() {
        if (this.ao == null) {
            this.ao = com.tencent.bugly.crashreport.common.info.b.i(this.H);
            com.tencent.bugly.proguard.x.a("Is it a virtual machine? " + this.ao, new Object[0]);
        }

        return this.ao;
    }

    public final boolean S() {
        if (this.ap == null) {
            this.ap = com.tencent.bugly.crashreport.common.info.b.j(this.H);
            com.tencent.bugly.proguard.x.a("Does it has hook frame? " + this.ap, new Object[0]);
        }

        return this.ap;
    }

    public final String T() {
        if (this.J == null) {
            this.J = AppInfo.g(this.H);
            com.tencent.bugly.proguard.x.a("Beacon channel " + this.J, new Object[0]);
        }

        return this.J;
    }
}
